<?php namespace Admin\Controller; 

use Hdphp\Controller\Controller;

//测试控制器
class OrderController extends CommonController{
	private $orderModel;
	public function __init(){
		Parent::__init();
		$this->orderModel = new \Common\Model\Orders;
	}
//	未支付订单
	public function unpay(){
		$this->orderModel->removeOrder();
		$total = $this->orderModel->where("status = 0")->count();
		$page = Page::row(10)->desc(array('pre'=>'<<上一页', 'next'=>'下一页>>'))->make($total);
		$unpayOrder = $this->orderModel->where("status = 0")->orderBy('time','DESC')->limit(Page::limit())->get();
		View::with('page',$page);
		View::with('unpayOrder',$unpayOrder);
		View::make();
	}
//	已支付订单
	public function onpay(){
		$this->orderModel->removeOrder();
		$total = $this->orderModel->where("status = 1")->count();
		$page = Page::row(10)->desc(array('pre'=>'<<上一页', 'next'=>'下一页>>'))->make($total);
		$onpayOrder = $this->orderModel->where("status = 1")->orderBy('time','DESC')->limit(Page::limit())->get();
		View::with('page',$page);
		View::with('onpayOrder',$onpayOrder);
		View::make();
	}
//	已支付订单
	public function unrec(){
		$this->orderModel->removeOrder();
		$total = $this->orderModel->where("status = 2")->count();
		$page = Page::row(10)->desc(array('pre'=>'<<上一页', 'next'=>'下一页>>'))->make($total);
		$unrecOrder = $this->orderModel->where("status = 2")->orderBy('time','DESC')->limit(Page::limit())->get();
		View::with('page',$page);
		View::with('unrecOrder',$unrecOrder);
		View::make();
	}
	
//	已支付订单
	public function isrec(){
		$this->orderModel->removeOrder();
		$total = $this->orderModel->where("status = 3")->count();
		$page = Page::row(10)->desc(array('pre'=>'<<上一页', 'next'=>'下一页>>'))->make($total);
		$isrecOrder = $this->orderModel->where("status = 3")->orderBy('time','DESC')->limit(Page::limit())->get();
		View::with('page',$page);
		View::with('isrecOrder',$isrecOrder);
		View::make();
	}
//	已取消订单
	public function quiet(){
		$this->orderModel->removeOrder();
		$total = $this->orderModel->where("status = 4")->count();
		$page = Page::row(10)->desc(array('pre'=>'<<上一页', 'next'=>'下一页>>'))->make($total);
		$quietOrder = $this->orderModel->where("status = 4")->orderBy('time','DESC')->limit(Page::limit())->get();
		View::with('page',$page);
		View::with('quietOrder',$quietOrder);
		View::make();
	}
//	确认收款
	public function pay(){
		if(!$this->orderModel->pay()) View::error($this->orderModel->getError());
		View::success('付款成功！',U('unpay'));
	}
//	确认发货
	public function shipment(){
		if(!$this->orderModel->shipment()) View::error($this->orderModel->getError());
		View::success('发货成功！',U('unpay'));
	}
//	确认发货
	public function haverec(){
		if(!$this->orderModel->haverec()) View::error($this->orderModel->getError());
		View::success('确认收货！',U('unpay'));
	}
	
//	删除订单
	public function del(){
		if(!$this->orderModel->del()) View::error($this->orderModel->getError());
		View::success('取消发货成功！',U('unpay'));
	}
	
	
}






